<style scoped>

</style>

<template>
    <div id="mailBoxConfigDiv">
        <Table border :columns="mailTableColumns" :data="allMailBoxList"></Table>
    </div>
</template>

<script>
export default {
    data() {
        return {
            //表格头配置
            mailTableColumns: [
                { title: '收件箱', key: 'name' },
                { title: '密码', key: 'password' },
                { 
                    title: '是否开启', 
                    key: 'isOpen',
                    render(row) {
                        var isOpen = row.isOpen;
                        var isOn = false;
                        if(isOpen==0){
                            isOn = true;
                        }
                        return '<i-switch :value="'+isOn+'"><Icon type="android-done" slot="open"></Icon><Icon type="android-close" slot="close"></Icon></i-switch>';
                    }
                },
                {
                    title: '操作',
                    key: 'action',
                    width: 120,
                    render(row) {
                        return '<i-button type="info"  @click="mailBoxDetailBtnClicked(row)" size="small">配置项</i-button>';
                    }
                }
            ],
            //表格数据配置
            allMailBoxList:[]
        }
    },
    mounted:function(){
        //获取收件箱数据
        this.getAllMailBoxList();
    },
    methods:{
        //获取所有收件箱数据
        getAllMailBoxList:function(){
            this.$http.get("mailBox/all").then(res=>{
                var jsonResponse = res.body;
                if(jsonResponse.returnCode ==='0'){
                    //请求成功
                    this.allMailBoxList = jsonResponse.returnData;
                }
            });
        },
        mailBoxDetailBtnClicked:function(row){
            console.log("row:"+JSON.stringify(row));
        }
    }
}
</script>